

export const jsonToQuestionScores = (jsonStr: string | undefined): API.QuestionScore[] => {
  // 将 JSON 字符串转换为对象数组
  const parsedQuestions: any[] = JSON.parse(jsonStr || '[]');

  // 将每个对象转换为 QuestionScore 类型
  const formattedQuestions: API.QuestionScore[] = parsedQuestions.map((item: any) => ({
    id: item.id,
    score: item.score
  }));

  return formattedQuestions;
};

export const QuestionScoresToJson = (questionScores: API.QuestionScore[] | undefined): string => {
  return JSON.stringify(questionScores);
};


export const  toQuestionVO = (question: API.Question ): API.QuestionVO => {
  const { createTime, isDelete, updateTime, ...rest } = question; 
  return { ...rest, picture: '', solution: '' }; 
}

